#pragma once

class System_Audio
{
protected:
	SmartPtr	<HGE_Impl>		m_pHGESystem;
	/* Main Audio Device */
	audiere :: AudioDevicePtr	m_pAudioDevice;

	/* Setting values */
	float m_fBGMVolume;
	float m_fSFXVolume;
	float m_fVoiceVolume;

	/* BGM Transisition use */
	float m_fVolume;
	float m_fDeltaV;
	std :: deque <std :: string>	TrackShifter;
	std :: string					CurrentBGM;

	audiere :: OutputStreamPtr		m_pBGMStream;

	/* SFX */
	std :: map <std :: string, audiere :: OutputStreamPtr> SFXStreams;
public:
	System_Audio();
	virtual ~System_Audio();
	
	bool Initialize();
	void Update(const float & Interval);
	
	void StopAll();

	void PlayBGM(const std :: string & File);
	void SetNextBGM(const std :: string & File, const float & FadeSpd);

	audiere :: OutputStreamPtr	GetSFX(const std :: string & File);
	bool						RemoveSFX(const std :: string & File);

	inline audiere :: AudioDevicePtr	Device()	{ return m_pAudioDevice; }
	inline audiere :: OutputStreamPtr	BGM()		{ return m_pBGMStream; }

	inline float GetBGMVolume()		{ return m_fBGMVolume; }
	inline float GetSFXVolume()		{ return m_fSFXVolume; }
	inline float GetVoiceVolume()	{ return m_fVoiceVolume; }
	inline void SetBGMVolume(float newVol)		{ m_pBGMStream->setVolume(m_fBGMVolume = newVol); }
	inline void SetVoiceVolume(float newVol)	{ m_fVoiceVolume = newVol; }
	inline void SetSFXVolume(float newVol)		
	{ 
		m_fSFXVolume = newVol; 
		std :: map <std :: string, audiere :: OutputStreamPtr> :: iterator it = SFXStreams.begin();
		for(;it != SFXStreams.end(); it++)
			it->second->setVolume(m_fSFXVolume);
	}
};

